package cn.stylefeng.guns.modular.highlight.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.highlight.service.HighlightService;
import cn.stylefeng.guns.modular.highlight.model.param.HighlightParam;

import javax.annotation.Resource;

/**
 * 光数据 控制器
 *
 * @author: raindeer
 * @date: 2021/05/24 14:50
 */
@RestController
public class HighlightController {

    @Resource
    private HighlightService highlightService;

    /**
     * 分页查询光数据
     *
     * @author raindeer
     * @date 2021/05/24 14:50
     */
    @GetMapping("/highlight/page")
    @BusinessLog(title = "光数据_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(HighlightParam highlightParam) {
        return new SuccessResponseData(highlightService.page(highlightParam));
    }

    /**
     * 获取全部光数据
     *
     * @author raindeer
     * @date 2021/05/24 14:50
     */
    @GetMapping("/highlight/list")
    @BusinessLog(title = "光数据_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(HighlightParam highlightParam) {
        return new SuccessResponseData(highlightService.list(highlightParam));
    }

    /**
     * 查看详情光数据
     *
     * @author raindeer
     * @date 2021/05/24 14:50
     */
    @GetMapping("/highlight/detail")
    @BusinessLog(title = "光数据_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(HighlightParam.detail.class) HighlightParam highlightParam) {
        return new SuccessResponseData(highlightService.detail(highlightParam));
    }

    /**
     * 添加光数据
     *
     * @author raindeer
     * @date 2021/05/24 14:50
     */
    @PostMapping("/highlight/add")
    @BusinessLog(title = "光数据_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(HighlightParam.add.class) HighlightParam highlightParam) {
        highlightService.add(highlightParam);
        return new SuccessResponseData();
    }

    /**
     * 删除光数据
     *
     * @author raindeer
     * @date 2021/05/24 14:50
     */
    @PostMapping("/highlight/delete")
    @BusinessLog(title = "光数据_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(HighlightParam.delete.class) HighlightParam highlightParam) {
        highlightService.delete(highlightParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑光数据
     *
     * @author raindeer
     * @date 2021/05/24 14:50
     */
    @PostMapping("/highlight/edit")
    @BusinessLog(title = "光数据_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(HighlightParam.edit.class) HighlightParam highlightParam) {
        highlightService.edit(highlightParam);
        return new SuccessResponseData();
    }


}
